﻿using System.Collections.Specialized;
using ScrappyDB.Membership;
using NUnit.Framework;
using System.Web.Profile;
using System;
using System.Configuration;

namespace ScrappyDB.IntegrationTests.Membership
{
    public class DummyProfileProvider : ProfileProvider
    {

        private string _appName = String.Empty;
        private Guid _appGuid = Guid.Empty;
        private string _providerName = String.Empty;

        public override void Initialize(string name, NameValueCollection config)
        {
            //_appGuid = new Guid(config["ApplicationGUID"]);
            _appGuid = Guid.NewGuid();
            _appName = config["ApplicationName"];
            _providerName = name;

            base.Initialize(name, config);
        }

        public override string Name
        {
            get { return _providerName; }
        }

        public override string ApplicationName
        {
            get { return _appName; }
            set { return; }
        }

        public override SettingsPropertyValueCollection GetPropertyValues
        (SettingsContext context, SettingsPropertyCollection collection)
        {
            //throw new NotImplementedException();
            var  result =  new SettingsPropertyValueCollection();
            result.Add(new SettingsPropertyValue(new SettingsProperty("Company"){PropertyType = typeof (string)}){PropertyValue = "xxx"});

            return result;
        }

        public override void SetPropertyValues
        (SettingsContext context, SettingsPropertyValueCollection collection)
        {
            throw new NotImplementedException();
        }

        public override int DeleteInactiveProfiles
        (ProfileAuthenticationOption authenticationOption,
        DateTime userInactiveSinceDate)
        {
            throw new NotImplementedException();
        }

        public override ProfileInfoCollection  FindInactiveProfilesByUserName(System.Web.Profile.ProfileAuthenticationOption a, string b, System.DateTime c, int d, int e, out int f)
        {
            throw new NotImplementedException();
        }

        public override ProfileInfoCollection FindProfilesByUserName(System.Web.Profile.ProfileAuthenticationOption a, string b, int c, int d, out int e)
        {
            throw new NotImplementedException();
        }

        public override ProfileInfoCollection GetAllInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption a,DateTime e, int b, int c, out int d)
        {
            throw new NotImplementedException();
        }        
        
        public override ProfileInfoCollection GetAllProfiles(System.Web.Profile.ProfileAuthenticationOption a, int b, int c, out int d)
        {
            throw new NotImplementedException();
        }

        public override int GetNumberOfInactiveProfiles(System.Web.Profile.ProfileAuthenticationOption a, System.DateTime b)
        {
            throw new NotImplementedException();
        }

        public override int  DeleteProfiles(string[] a)
        {
            throw new NotImplementedException();
        }

        public override int  DeleteProfiles(System.Web.Profile.ProfileInfoCollection a)
        {
            throw new NotImplementedException();
        }


        /*
         * Custom ProfileManger methods
         */
        public int GetTotalNumberofProfiles()
        {
            throw new NotImplementedException();
        }
    }

    public class ProfileCommon2 : ProfileBase
    {
        public virtual  string Company
        {
            get { return base["Company"] as string; }
            set { base["Company"] = value; }
        }

        public static ProfileCommon2 GetProfile(string username)
        {
            return Create(username) as ProfileCommon2;
        }
    }

    /// <summary>
    ///This is a test class for SdbProfileProviderTest and is intended
    ///to contain all SdbProfileProviderTest Unit Tests
    ///</summary>
    [TestFixture]
    public class SdbProfileProviderTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [Test, Ignore]
        public void ProfileTest_CustomClass()
        {
            string expected = "ACME";
            var profile = ProfileCommon2.GetProfile("testUser");

            profile.Company = expected;

            profile.Save();

            var profile2 = ProfileCommon2.GetProfile("testUser");

            Assert.AreEqual(expected, profile2.Company);

        }

        [Test, Ignore]
        public void ProfileTest_AppConfig()
        {
            string expected = "TOAST";
            var profile = ProfileCommon2.GetProfile("testUser");

            profile.SetPropertyValue("TestProperty", expected);
            //profile.Company = expected;

            profile.Save();

            var profile2 = ProfileCommon2.GetProfile("testUser");

            Assert.AreEqual(expected, profile2.GetPropertyValue("TestProperty"));

        }

        /// <summary>
        ///A test for SetPropertyValues
        ///</summary>
        [Test, Ignore]
        public void SetPropertyValuesTest()
        {
            SdbProfileProvider target = new SdbProfileProvider(); 
            SettingsContext context = null; 
            SettingsPropertyValueCollection ppvc = null; 
            target.SetPropertyValues(context, ppvc);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }


        /// <summary>
        ///A test for GetPropertyValues
        ///</summary>
        [Test, Ignore]
        public void GetPropertyValuesTest()
        {
            SdbProfileProvider target = new SdbProfileProvider(); 
            SettingsContext context = null; 
            SettingsPropertyCollection ppc = null; 
            SettingsPropertyValueCollection expected = null; 
            SettingsPropertyValueCollection actual;
            actual = target.GetPropertyValues(context, ppc);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }


        /// <summary>
        ///A test for GetNumberOfInactiveProfiles
        ///</summary>
        [Test, Ignore]
        public void GetNumberOfInactiveProfilesTest()
        {
            SdbProfileProvider target = new SdbProfileProvider(); 
            ProfileAuthenticationOption authenticationOption = new ProfileAuthenticationOption(); 
            DateTime userInactiveSinceDate = new DateTime(); 
            int expected = 0; 
            int actual;
            actual = target.GetNumberOfInactiveProfiles(authenticationOption, userInactiveSinceDate);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetAllProfiles
        ///</summary>
        [Test, Ignore]
        public void GetAllProfilesTest()
        {
            SdbProfileProvider target = new SdbProfileProvider(); 
            ProfileAuthenticationOption authenticationOption = new ProfileAuthenticationOption(); 
            int pageIndex = 0; 
            int pageSize = 0; 
            int totalRecords = 0; 
            int totalRecordsExpected = 0; 
            ProfileInfoCollection expected = null; 
            ProfileInfoCollection actual;
            actual = target.GetAllProfiles(authenticationOption, pageIndex, pageSize, out totalRecords);
            Assert.AreEqual(totalRecordsExpected, totalRecords);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetAllInactiveProfiles
        ///</summary>
        [Test, Ignore]
        public void GetAllInactiveProfilesTest()
        {
            SdbProfileProvider target = new SdbProfileProvider(); 
            ProfileAuthenticationOption authenticationOption = new ProfileAuthenticationOption(); 
            DateTime userInactiveSinceDate = new DateTime(); 
            int pageIndex = 0; 
            int pageSize = 0; 
            int totalRecords = 0; 
            int totalRecordsExpected = 0; 
            ProfileInfoCollection expected = null; 
            ProfileInfoCollection actual;
            actual = target.GetAllInactiveProfiles(authenticationOption, userInactiveSinceDate, pageIndex, pageSize, out totalRecords);
            Assert.AreEqual(totalRecordsExpected, totalRecords);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for FindProfilesByUserName
        ///</summary>
        [Test, Ignore]
        public void FindProfilesByUserNameTest()
        {
            SdbProfileProvider target = new SdbProfileProvider(); 
            ProfileAuthenticationOption authenticationOption = new ProfileAuthenticationOption(); 
            string usernameToMatch = string.Empty; 
            int pageIndex = 0; 
            int pageSize = 0; 
            int totalRecords = 0; 
            int totalRecordsExpected = 0; 
            ProfileInfoCollection expected = null; 
            ProfileInfoCollection actual;
            actual = target.FindProfilesByUserName(authenticationOption, usernameToMatch, pageIndex, pageSize, out totalRecords);
            Assert.AreEqual(totalRecordsExpected, totalRecords);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for FindInactiveProfilesByUserName
        ///</summary>
        [Test, Ignore]
        public void FindInactiveProfilesByUserNameTest()
        {
            SdbProfileProvider target = new SdbProfileProvider(); 
            ProfileAuthenticationOption authenticationOption = new ProfileAuthenticationOption(); 
            string usernameToMatch = string.Empty; 
            DateTime userInactiveSinceDate = new DateTime(); 
            int pageIndex = 0; 
            int pageSize = 0; 
            int totalRecords = 0; 
            int totalRecordsExpected = 0; 
            ProfileInfoCollection expected = null; 
            ProfileInfoCollection actual;
            actual = target.FindInactiveProfilesByUserName(authenticationOption, usernameToMatch, userInactiveSinceDate, pageIndex, pageSize, out totalRecords);
            Assert.AreEqual(totalRecordsExpected, totalRecords);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for DeleteProfiles
        ///</summary>
        [Test, Ignore]
        public void DeleteProfilesTest1()
        {
            SdbProfileProvider target = new SdbProfileProvider(); 
            ProfileInfoCollection profiles = null; 
            int expected = 0; 
            int actual;
            actual = target.DeleteProfiles(profiles);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for DeleteProfiles
        ///</summary>
        [Test, Ignore]
        public void DeleteProfilesTest()
        {
            SdbProfileProvider target = new SdbProfileProvider(); 
            string[] usernames = null; 
            int expected = 0; 
            int actual;
            actual = target.DeleteProfiles(usernames);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }


        /// <summary>
        ///A test for DeleteInactiveProfiles
        ///</summary>
        [Test, Ignore]
        public void DeleteInactiveProfilesTest()
        {
            SdbProfileProvider target = new SdbProfileProvider(); 
            ProfileAuthenticationOption authenticationOption = new ProfileAuthenticationOption(); 
            DateTime userInactiveSinceDate = new DateTime(); 
            int expected = 0; 
            int actual;
            actual = target.DeleteInactiveProfiles(authenticationOption, userInactiveSinceDate);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }
}
